package outfox.smt.word.alignment;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class Checker {
	public static void checkNumAlign() throws IOException{
		File file=new File("alignmentbatch.2009.txt");
		BufferedReader br=new BufferedReader(new FileReader(file));
		String line;
		int count=0;
		while((line=br.readLine())!=null){
			if(line.startsWith("Starting Document Alignment")){
				String numcount=null;
				String numaligncount=null;
				String line2;
				while((line2=br.readLine())!=null){
					if(line2.startsWith("Number Text Count")){
						numcount=line2;
						break;
					}
				}
				String[]s1=numcount.split(":");
				int c1=Integer.parseInt(s1[1]);
				int c2=Integer.parseInt(s1[2]);
				int min=c1<c2?c1:c2;
				numaligncount=br.readLine();
				s1=numaligncount.split(":");
				int ac=Integer.parseInt(s1[1]);
				double p=(double)ac/(double)min;
				if(p<0.5){
					count++;
					System.out.println("----");
					System.out.println(line);
					System.out.println(numcount);
					System.out.println(numaligncount);
				}
			}
		}
		System.out.println("------");
		System.out.println(count);
	}

	private static void checkParaAlign() throws IOException {
		File file=new File("alignmentbatch.txt");
		BufferedReader br=new BufferedReader(new FileReader(file));
		String line;
		int count=0;
		while((line=br.readLine())!=null){
			if(line.startsWith("Starting Document Alignment")){
				String paraaligncount=null;
				String line2;
				while((line2=br.readLine())!=null){
					if(line2.startsWith("Paragraph Alignment Count")){
						paraaligncount=line2;
						break;
					}
				}
				String[]s1=paraaligncount.split(":");
				int ac=Integer.parseInt(s1[1]);
				if(ac>500&&ac<1000){
					count++;
					System.out.println("----");
					System.out.println(line);
					System.out.println(paraaligncount);
				}
			}
		}
		System.out.println("------");
		System.out.println(count);
	}
	public static void main(String[]args) throws IOException{
		//checkNumAlign();
		checkParaAlign();
	}
}
